package GUI;
/**hofit**/
import javax.swing.JPanel;
import java.awt.Color;

import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.JEditorPane;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.UIManager;
import java.awt.Font;
import javax.swing.JButton;

import Client.BusinessImplements;
import Controler.Access_pass_panel;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.SystemColor;
import javax.swing.border.LineBorder;
/**
 * the screen that recover password - sent the password to the email of the user
 * @author User
 *
 */
public class Accesss_pass_panel extends Abstract_Jpanel {
	private final JPanel panel = new JPanel();
	private final JLabel lblId = new JLabel("enter ID:");
	private final JTextField txtID = new JTextField();
	private final JLabel lblThePassworldWill = new JLabel("the passworld will be sent to your email address");
	public final JButton btnClose = new JButton("close");
	public final JButton btnGo = new JButton("GO");

	/**
	 * Create the panel.
	 */
	public Accesss_pass_panel() {
		txtID.setBounds(83, 39, 141, 20);
		txtID.setColumns(10);

		initGUI();
	}
	/**
	 * create the screen
	 */
	private void initGUI() {
		setLayout(null);
		panel.setBorder(new LineBorder(SystemColor.activeCaption, 6));
		panel.setBackground(SystemColor.inactiveCaption);
		panel.setBounds(10, 29, 430, 167);
		
		add(panel);
		panel.setLayout(null);
		lblId.setFont(new Font("Tahoma", Font.PLAIN, 16));
		lblId.setBounds(10, 40, 80, 14);
		
		panel.add(lblId);
		
		panel.add(txtID);
		lblThePassworldWill.setFont(new Font("Segoe Print", Font.PLAIN, 15));
		lblThePassworldWill.setForeground(new Color(128, 0, 0));
		lblThePassworldWill.setBounds(10, 87, 397, 30);
		
		panel.add(lblThePassworldWill);
		/**
		 * parameter: id
		 * return: true or false
		 * being done when the user press go
		 *  check if the user exist in the system if the user exist sent email
		 *   with password and inform the user if not pop up message to the user
		 */
		btnGo.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Access_pass_panel pan=new Access_pass_panel();
				if (!pan.recoverPassword(txtID.getText()))
					JOptionPane.showMessageDialog(null, "The user didn't exist in the system" );
				else
					JOptionPane.showMessageDialog(null, "The password sent to your email" );
			}
		});
		btnGo.setFont(new Font("Tahoma", Font.PLAIN, 14));
		btnGo.setBounds(251, 33, 80, 30);
		
		panel.add(btnGo);
		/**
		 * return to the sign in screen
		 */
		btnClose.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setBounds(100, 100, 499, 337);
				on_screen_unload();
				Log_in_panel nextscreen = new Log_in_panel();
				BusinessImplements.GetInstance().getMainFrame().setContentPane(nextscreen);
				nextscreen.setSize(getMaximumSize());
				nextscreen.on_screen_load();
				
			}
		});
		btnClose.setFont(new Font("Tahoma", Font.PLAIN, 14));
		btnClose.setBounds(306, 207, 99, 37);
		
		add(btnClose);
	}
	@Override
	public void next_screen() {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void prev_screen() {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void on_screen_load() {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void on_screen_unload() {
		// TODO Auto-generated method stub
		
	}
}
